package gases.as3.librarys.components.ui.resize
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	
	import gases.as3.librarys.components.ui.GUIComponents;
	import gases.as3.util.ResizeAlignMode;
	import gases.as3.util.ResizeUtil;
	
	public class ResizeComponent extends GUIComponents
	{
		public static const DEFAULT_WIDTH:Number = 1000;
		public static const DEFAULT_HEIGHT:Number = 600;
		
		public function ResizeComponent()
		{
			super();
		}
		
		override protected function initialization():void
		{
			this.addEventListener(Event.ADDED_TO_STAGE,addToStage);
		}
		
		private function addToStage(e:Event):void
		{
			if(stage)
			{
//				if(stage.stage)
//				{
//					stage.stage.addEventListener(Event.RESIZE,onResize);
//				}
//				else
//				{
					stage.addEventListener(Event.RESIZE,onResize);
//				}
			}
		}
		
		private function onResize(e:Event):void
		{
			resizeView();
		}
		
		public function resizeView():void
		{
			if(stage)
			{
//				if(stage.stage)
//				{
//					ResizeUtil.silder(this,stage.stage,hAlign,vAlign);
//				}
//				else
//				{
					ResizeUtil.silder(this,stage,hAlign,vAlign);
//				}
			}
		}
		
		
		public function get vAlign():String
		{
			return _vAlign;
		}
		
		public function set vAlign(value:String):void
		{
			_vAlign = value;
		}
		
		public function get hAlign():String
		{
			return _hAlign;
		}
		
		public function set hAlign(value:String):void
		{
			_hAlign = value;
		}
		
		private var _vAlign:String = "middle";
		private var _hAlign:String = "center";
	}
}